package com.kaka.bus.view;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.support.v7.widget.AppCompatButton;
import android.util.AttributeSet;

import com.kaka.bus.R;

/**
 * Created by OnionMac on 2018/1/17.
 */

public class EvaluateButton extends AppCompatButton{

    private int mNormal;
    private int mPress;

    private boolean mCheck;

    public EvaluateButton(Context context) {
        super(context);
    }

    public EvaluateButton(Context context, AttributeSet attrs) {
        super(context, attrs);

        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.EvaluateButton);

        mNormal = a.getResourceId(R.styleable.EvaluateButton_eva_bg_normal, R.drawable.vip_top_bg_uncheck);
        mPress = a.getResourceId(R.styleable.EvaluateButton_eva_bg_press, R.drawable.vip_top_bg_check_eva);

        a.recycle();

        setCheck(false);
    }

    public void setCheck(boolean check){
        mCheck = check;

        if(mCheck){
            setBackgroundResource(mPress);
            setTextColor(Color.WHITE);
        }else{
            setTextColor(Color.parseColor("#333333"));
            setBackgroundResource(mNormal);
        }
    }

    public boolean isCheck(){
        return mCheck;
    }
}
